import * as vscode from 'vscode';
import * as Fs from 'fs';
import * as Path from 'path';
export function mkdirsSync(filepath: string): void {
  const rootPath = vscode.workspace.rootPath || '';
  const arr = filepath.split('/'); // ['', 'src', 'addEditDetailDst', 'functions'] '/src/addEditDetailDst/functions'
  let dir = arr[1];
  for (let i = 1; i < arr.length; i++) {
    let path = Path.join(rootPath, '/' + dir);
    if (!Fs.existsSync(path)) {
      Fs.mkdirSync(path);
      // }
    }
    dir = dir + '/' + arr[i+1];
  }
}

export const messageHandler = {
  command(commandName: string, message: any) {
    vscode.commands.executeCommand(`hello.${commandName}`, message.params);
    // 'hello.helloWorld';
  },
  log(msg: string) {
    vscode.window.showInformationMessage(`${msg} !`);
  }
};